package com.appkubes.mall.admin.application.goods.category.service.impl;

import com.appkubes.mall.admin.application.goods.category.dao.CategoryDao;
import com.appkubes.mall.admin.application.goods.category.service.GoodsCategoryService;
import com.appkubes.mall.core.entity.MallGoodsCategory;
import com.appkubes.mall.core.service.impl.BaseMallGoodsCategoryServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsCategoryServiceImpl extends BaseMallGoodsCategoryServiceImpl implements GoodsCategoryService {

    @Autowired
    CategoryDao categoryDao;

    public IPage<MallGoodsCategory> querySelective(String name, Integer pageNo, Integer pageSize, String sort) {
        QueryWrapper<MallGoodsCategory> queryWrapper = new QueryWrapper();
        queryWrapper.like("name", name);
        queryWrapper.orderByDesc(sort);

        IPage<MallGoodsCategory> page = new Page<>(pageNo, pageSize);
        IPage<MallGoodsCategory> list = this.getBaseMapper().selectPage(page, queryWrapper);
        return list;
    }

    public List<MallGoodsCategory> getByState(Integer state) {
        MallGoodsCategory query = new MallGoodsCategory();
        query.setState(state);
        return this.selectListByEntity(query);
    }


}
